I've just downloaded the release version of .NET Core 3.0.100
It was installed alongside older version that I have:
When I try to run dotnet restore for a project that targets .NET Core 3 (<TargetFramework>netcoreapp3.0</TargetFramework>), I get this error
C:\Program Files\dotnet\sdk\2.2.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.
I have a global.json file that explicitly states that I need the 3.0.100 SDK
{
"sdk": {
"version": "3.0.100"
}
}
I know that I can edit the MSBuildSDKsPath env variable to point to the 3.0.100 SDK, and it works, but I don't want to do it, I have other projects on my machine that still need to use older versions of .NET Core.
Is there a way to make the dotnet tool use the SDK that's stated in global.json instead of the one in MSBuildSDKsPath?
Edit: I use Visual Studio Code
I got this error in Azure DevOps with .NET 6:
error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
Solved by including the SDK like this:
steps:
- task: UseDotNet@2
displayName: 'Install .NET 6 SDK'
inputs:
version: 6.0.x
performMultiLevelLookup: true
Github thread about the issue:
You also have to update your visual studio to the minimum supported version:
visual studio v16.3visual studio v16.5visual studio v16.6 latest previewvisual studio v17.0 latest preview(https://dotnet.microsoft.com/download/dotnet-core/3.0)
(https://dotnet.microsoft.com/download/dotnet-core/3.1)
(https://dotnet.microsoft.com/download/dotnet/5.0)